{template 'common/header'}
<style>
    .header-box{
        position: absolute;
        width: 100%;
        top: 0;
        height: 25%;
    }
    #main-box{
        position: absolute;
        width: 100%;
        top: 25%;
        height: 75% !important;
        overflow: auto;
    }
    #info-bar{
        position: absolute;
        width: 100%;
        bottom: 0;
    }

</style>
<title>个人中心</title>
<div class="xhq_body body_bg">
    <div id="container" style="height: 100%;"></div>
</div>
<script id="member_center" type="text/html">
    <div class="header-box ">
        <div class="container-fluid vip-info-bg" id="info-box">
            <div class="user-head-pic pull-left margin-sm">
                <img src="<%member.avatar%>" alt="" class="img-responsive img-circle">
            </div>
            <div class="container-fluid pull-left margin-sm">
                <ul class="list-unstyled vip-info-list">
                    <li><h6 class="pull-left">昵称：</h6><h6 class="pull-left"><%member.nickname%></h6><h6 class="pull-left" style="margin-left: 10px"><a class="blue_font" href="{php echo $this->createMobileUrl('member/info')}">账号设置</a></h6></li>
                    <li><h6 class="pull-left">花名：</h6><h6 class="pull-left">{if !empty($set['shop']['levelurl'])}onclick='location.href="{$set['shop']['levelurl']}"'{/if}<%level.levelname%> {if !empty($set['shop']['levelurl'])}<i class='fa fa-question-circle' ></i>{/if}</h6></li>
                    <li><h6 class="pull-left">编号：</h6><h6 class="pull-left"><%member.id%></h6></li>
                </ul>
            </div>
        </div>
        <div class="container-fluid amount_detail_banner" id="info-bar">
            <div class="row">
                <div class="col-xs-6 pull-left">
                    <div class="row border-right">
                        <h5 class="text-center white_font">销售额：<%totalPrice%>元</h5>
                    </div>
                </div>
                <div class="col-xs-6 pull-left">
                    <div class="row">
                        <h5 class="text-center white_font">我的业绩：<%totalCommission%>元</h5>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="container-fluid black-bg" id="info-bar">
        <div class="row">
            <div class="col-xs-12 pull-left main_bg">
                <div class="row">
                    <h5 class="text-center white_font">订单详情</h5>
                </div>
            </div>
        </div>
    </div>
    <div id="main-box" style="height: 100%;">
        <div class="container-fluid h5">

            <span class="text-left h5">{if $status == 0}未付款订单（<%unPayNum%>）{else}已付款订单（<%hasPayNum%>）{/if}</span>
        </div>
        <ul class="list-group order-box">
            <%each list as order%>
            <li class="list-group-item">
                <div class="order-info">
                    <span class="order-no"><%order.ordersn%></span>
                    <span><%order.createtime%></span>
                </div>
                <div class="order-info-price">
                    <span>+<%order.commission%></span>
                    <span class="order-state"><%order.status%></span>
                </div>
            </li>
            <%/each%>
        </ul>
    </div>
    <div style="height:46px;"></div>
        <footer class="footer container-fluid">
            <ul class="nav row nav-pills navbar-fixed-bottom navbar-inverse four-items main_bg navbar-bottom">
                <li role="presentation"><a href="{php echo $this->footer['first']['url']}"><span class="glyphicon glyphicon-home"></span><span>立即购买</span></a></li>
                <li role="presentation"><a href="{php echo $this->createMobileUrl('order')}"><span class="glyphicon glyphicon-list"></span><span>我的订单</span></a></li>
                <li role="presentation"><a href="{php echo $this->createMobileUrl('member')}"><span class="glyphicon glyphicon-user "></span><span>会员中心</span></a></li>
                <li role="presentation"><a href="{php echo $this->createPluginMobileUrl('commission/shares')}"><span class="glyphicon glyphicon-qrcode "></span><span>我的二维码</span></a></li>
            </ul>
        </footer>
</script>
<script language="javascript">
    var page = 1;
    var current_status = '';
    require(['tpl', 'core'], function(tpl, core) {

//        core.json('member/order',{},function(json){
//
//            //console.log(json.result);
//
//            $('#container').html(  tpl('member_center',json.result) );
//            var withdrawmoney = {php echo empty($set['trade']['withdrawmoney'])?0:floatval($set['trade']['withdrawmoney'])};
//
//            $('#btnwithdraw').click(function(){
//
//                if(json.result.member.credit2<=0){
//                    core.tip.show('无余额可提!');
//                    return;
//                }
//                if(withdrawmoney>0 && json.result.member.credit2<withdrawmoney){
//                    core.tip.show('满' +withdrawmoney + "元才能提现!" );
//                    return;
//                }
//                location.href = core.getUrl('member/withdraw');
//            })
//
//        },true);

        function bindScroller(){
            //加载更多
            var loaded = false;
            var stop = true;
            $(window).scroll(function () {
                if (loaded) {
                    return;
                }
                totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());
                if ($(document).height() <= totalheight) {

                    if (stop == true) {
                        stop = false;
                        $('#container').append('<div id="order_loading"><i class="fa fa-spinner fa-spin"></i> 正在加载...</div>');
                        page++;
                        core.pjson('commission/order', {status:current_status,page: page}, function (morejson) {
                            stop = true;
                            $('#order_loading').remove();
                            $("#container").append(tpl('member_center', morejson.result));
                            if (morejson.result.list.length < morejson.result.pagesize) {
                                $("#container").append('<div id="order_loading">已经加载完全部订单</div>');
                                loaded = true;
                                $(window).scroll = null;
                                return;
                            }
                        }, true);
                    }
                }
            });
        }

        function getOrder(status) {
            core.json('member/order', {status:status, page: page}, function (json) {
                    console.log(json);

                $('#container').html(tpl('member_center', json.result));
                bindScroller();
            }, true);
        }

        getOrder({$status});

    })

</script>
{php $show_footer=true}
{php $footer_current='member'}

